from flask import Flask
from .config import Config
# from .databases import db_main, db_analytics
from .databases import db_main
def create_app():
    app = Flask(__name__)
    app.config.from_object(Config)

    # 初始化数据库
    db_main.init_app(app)
    # db_analytics.init_app(app)

    # 注册蓝图

    # 从路由模块直接导入蓝图
    # from .routes.user_routes import user_bp
    # from .routes.product_routes import product_bp

    # 从 routes 包导入蓝图 (需要 __init__.py 中导出)
    from .routes import user_bp, product_bp

    # from .routes import user_bp
    app.register_blueprint(user_bp, url_prefix='/api/users')
    app.register_blueprint(product_bp, url_prefix='/api/products')
    # app.register_blueprint(order_bp, url_prefix='/api/orders')

    return app